﻿#include "XQUserInfo.h"

XQUserInfo::XQUserInfo(QObject* parent)
	:QObject(parent)
{
	init();
}

XQUserInfo::~XQUserInfo()
{
}

XQAccountData XQUserInfo::accountData()const
{
	XQAccountData data;
	data.portrait_data = m_headPortrait.toImage();
	data.account = account();
	data.password = password();
	data.email = email();
	data.phone = phone();
	data.name = name();
	data.gender = gender();
	data.permission = permission();
	return data;
}

QPixmap XQUserInfo::portrait()const
{
	return m_headPortrait;
}

QString XQUserInfo::account()const
{
	return m_account;
}

QString XQUserInfo::password() const
{
	return m_password;
}

QString XQUserInfo::email() const
{
	return m_email;
}

QString XQUserInfo::phone() const
{
	return m_phone;
}

QString XQUserInfo::name() const
{
	return m_name;
}

GenderType XQUserInfo::gender() const
{
	return m_gender;
}

Permission XQUserInfo::permission() const
{
	return m_permission;
}

userState XQUserInfo::state() const
{
	return m_state;
}

QDateTime XQUserInfo::ctime() const
{
	return m_ctime;
}

QDateTime XQUserInfo::mtime() const
{
	return m_mtime;
}
void XQUserInfo::setAccountData(const XQAccountData& data)
{
	setPortrait(QPixmap::fromImage(data.portrait_data));
	setAccount(data.account);
	setPassword(data.password);
	setEmail(data.email);
	setPhone(data.phone);
	setName(data.name);
	setGender(data.gender);
	setPermission(data.permission);

}
void XQUserInfo::setPortrait(const QPixmap& pixmap)
{
	m_headPortrait = pixmap;
	emit portraitChange(pixmap);
}
void XQUserInfo::setAccount(const QString& account)
{
	if (account == m_account)
		return;
	m_account = account;
	emit accountChange(account);
}

void XQUserInfo::setPassword(const QString& password)
{
	if (m_password == password)
		return;
	m_password = password;
	emit passwordChange(password);
}

void XQUserInfo::setEmail(const QString& email)
{
	if (m_email == email)
		return;
	m_email = email;
	emit emailChange(email);
}

void XQUserInfo::setPhone(const QString& phone)
{
	if (m_phone == phone)
		return;
	m_phone = phone;
	emit phoneChange(phone);
}

void XQUserInfo::setName(const QString& name)
{
	if (m_name == name)
		return;
	m_name = name;
	emit nameChange(name);
}

void XQUserInfo::setGender(const GenderType& gender)
{
	if (m_gender == gender)
		return;
	m_gender = gender;
	emit genderChange(gender);
}

void XQUserInfo::setPermission(const Permission& permission)
{
	if (m_permission == permission)
		return;
	m_permission = permission;
	emit permissionChange(m_permission);
}

void XQUserInfo::setState(userState state)
{
	if (m_state == state)
		return;
	m_state = state;
	emit stateChange(m_state);
}

void XQUserInfo::setCTime(const QDateTime& time)
{
	if (m_ctime == time)
		return;
	m_ctime = time;
}

void XQUserInfo::setMTime(const QDateTime& time)
{
	if (m_mtime == time)
		return;
	m_mtime = time;
}

void XQUserInfo::init()
{
}
